//
//  RootViewController.m
//  UI10_通讯录辅助
//
//  Created by dllo on 15/11/20.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "RootViewController.h"
#import "ChineseToPinyin.h"

@interface RootViewController ()<UINavigationControllerDelegate, UIImagePickerControllerDelegate>

@property (nonatomic, retain) UIImageView *imageV;

@end

@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    self.imageV = [[UIImageView alloc] initWithFrame:CGRectMake(50, 50, 200, 200)];
    self.imageV.image = [UIImage imageNamed:@"image1.jpg"];
    self.imageV.userInteractionEnabled = YES;
    [self.view addSubview:self.imageV];
    [_imageV release];
    
    UITapGestureRecognizer *tapGR = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [self.imageV addGestureRecognizer:tapGR];
    [tapGR release];
   
    NSString *str = [[ChineseToPinyin pinyinFromChiniseString:@"王宁"] substringToIndex:1];
    NSLog(@"%@", str);
   
}

- (void)tapAction:(UITapGestureRecognizer *)sender
{

    UIImagePickerController *imagePC = [[UIImagePickerController alloc] init];
    
    imagePC.delegate = self;
    
//    imagePC.allowsEditing = YES;
    
    
    [self presentViewController:imagePC animated:YES completion:^{
        
        
    }];
    [imagePC release];
    
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    self.imageV.image = [info objectForKeyedSubscript:@"UIImagePickerControllerOriginalImage"];
    
    [self dismissViewControllerAnimated:YES completion:^{
        
        
    }];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
